import apis from '../../http/apis/apis'
export default {
    namespaced: true,
    state: {
        tableData: [
        ],
        totals: 1,
    },
    mutations: {
        renderList(state, data) {
            state.totals = data.totalSize
            state.tableData = data.data
            // state.tableData.forEach(e => {
            //     if(e.state=1){
            //         e.state="审批中"
            //     }
            // });
        },
    },
    actions: {
        //渲染待审核的理赔，state=1
        async getClaimApply(context, content) {
            let data = await apis.claims.getClaimApply(content)
            if (data.code) {
                context.commit('renderList', data.data)
            }
        },
        //不同意
        async noClaimsApply(context, content) {
            let {_id,pageSize,currentPage}=content
            let data = await apis.claims.noClaimsApply({ _id})
            console.log(data);
            if (data.code) {
                context.dispatch('getClaimApply',{pageSize,currentPage})
            }
        },
        //同意
        async okClaimsApply(context, content) {
            // console.log(content);
            let {_id,pageSize,currentPage}=content
            let data = await apis.claims.okClaimsApply({ _id})
            console.log(data);
            if (data.code) {
                context.dispatch('getClaimApply',{pageSize,currentPage})
            }
        },
        //渲染已审核的理赔，state！=1
        async getFinishClaimApply(context, content) {
            let data = await apis.claims.getFinishClaimApply(content)
            console.log(data);
            if (data.code) {
                context.commit('renderList', data.data)
            }
        },

    }
}